package com.yex.dao.otc;


import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yex.entity.otc.OtcEntrust;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * otc 委托表 Mapper 接口
 * </p>
 *
 * @author Little Liu
 * @since 2018-05-02
 */
public interface OtcEntrustDao extends BaseMapper<OtcEntrust> {

    Integer findEntrustTypeUser(@Param("coinId") Integer coinId, @Param("userId") Integer userId, @Param("type") Integer type);

    List<OtcEntrust> otcEntrustBuyList(@Param("coinId") Integer coinId);

    List<OtcEntrust> otcEntrustSellList(@Param("coinId") Integer coinId);

    List<OtcEntrust> otcEntrustBuyUserList(@Param("coinId") Integer coinId, @Param("userId") Integer userId);

    List<OtcEntrust> otcEntrustSellUserList(@Param("coinId") Integer coinId, @Param("userId") Integer userId);

    Integer updateAddDealCount(@Param("entrustId") Integer entrustId, @Param("count") BigDecimal count, @Param("price") BigDecimal price, @Param("dealFees") BigDecimal dealFees);

    Integer updateSubDealCount(@Param("entrustId") Integer entrustId, @Param("count") BigDecimal count, @Param("price") BigDecimal price, @Param("dealFees") BigDecimal dealFees);


    /**
     * 昨日委托买单数
     * @param coinId 法币id
     * @return
     */
    Integer findBuyUnit(@Param("coinId") Integer coinId);

    /**
     * 昨日委托卖单数
     * @param coinId 法币id
     * @return
     */
    Integer findSellUnit(@Param("coinId") Integer coinId);

    /**
     * 昨日委托买单币数
     * @param coinId 法币id
     * @return
     */
    BigDecimal findBuyCoinUnit(@Param("coinId") Integer coinId);


    /**
     * 昨日委托卖单币数
     * @param coinId 法币id
     * @return
     */
    BigDecimal findSellCoinUnit(@Param("coinId") Integer coinId);



    /**
     * 昨日指数价格委托单数
     * @param coinId 法币id
     * @return
     */
    Integer findExponentUnit(@Param("coinId") Integer coinId);


    /**
     * 昨日指数价格委托单币数
     * @param coinId 法币id
     * @return
     */
    BigDecimal findExponentCoinUnit(@Param("coinId") Integer coinId);

    List<Map> findYesterdayFees();

	int updateBuyFrozen(OtcEntrust updateOtcEntrust);


    Integer updateFinishCount(@Param("entrustId") Integer entrustId, @Param("count") BigDecimal count, @Param("prize") BigDecimal prize, @Param("finishFees") BigDecimal finishFees);

    Integer updateFinishStatus(@Param("entrustId") Integer entrustId, @Param("count") BigDecimal count);

    Integer updateSuspendStatus(@Param("entrustId") Integer entrustId);

    Integer updateUnSuspendStatus(@Param("entrustId") Integer entrustId);

    Integer updateCancelStatus(@Param("entrustId") Integer entrustId);

    Integer updateFulfilStatus(@Param("entrustId") Integer entrustId);

    Integer updateSysAuto(@Param("entrustId") Integer entrustId);

    Integer updateUnSysAuto(@Param("entrustId") Integer entrustId);

    Integer updateNormalStatus(@Param("entrustId") Integer entrustId);


    List<OtcEntrust> otcEntrustUserList(@Param("userId") Integer userId);
}
